# coding=utf-8
import pandas as pd

class check_data_model:
    '''
    @method: pandas
    @:return result_inner_list，result_inner_tuple，
     result_left_list, result_left_tuple，
     result_right_list, result_right_tuple
    '''
    def check_pandas_listDatas(self, left_dataFrame, right_dataFrame, condition):
        result_inner = pd.merge(left_dataFrame, right_dataFrame, how='inner', on=[condition])

        result_left_only = left_dataFrame.append(right_dataFrame)
        result_left_only = result_left_only.append(right_dataFrame)
        result_left = result_left_only.drop_duplicates(subset=[condition], keep=False)

        result_right_only = right_dataFrame.append(left_dataFrame)
        result_right_only = result_right_only.append(left_dataFrame)
        result_right = result_right_only.drop_duplicates(subset=[condition], keep=False)

        result_inner_list = []
        result_left_list = []
        result_right_list = []

        for inner_item in result_inner.to_records():
            temp_data = inner_item[1]
            result_inner_list.append(temp_data)
        for left_item in result_left.to_records():
            temp_data = left_item[1]
            result_left_list.append(temp_data)
        for right_item in result_right.to_records():
            temp_data = right_item[1]
            result_right_list.append(temp_data)

        return (result_inner_list, result_left_list, result_right_list)

    def check_pandas_tupleDatas(self, left_dataFrame, right_dataFrame, condition):
        result_inner = pd.merge(left_dataFrame, right_dataFrame, how='inner', on=[condition])

        result_left_only = left_dataFrame.append(right_dataFrame)
        result_left_only = result_left_only.append(right_dataFrame)
        result_left = result_left_only.drop_duplicates(subset=[condition], keep=False)

        result_right_only = right_dataFrame.append(left_dataFrame)
        result_right_only = result_right_only.append(left_dataFrame)
        result_right = result_right_only.drop_duplicates(subset=[condition], keep=False)

        result_inner_tuple = []
        result_left_tuple = []
        result_right_tuple = []

        for inner_item in result_inner.to_records():
            temp_data = inner_item[1]
            result_inner_tuple.append((temp_data))
        for left_item in result_left.to_records():
            temp_data = left_item[1]
            result_left_tuple.append((temp_data))
        for right_item in result_right.to_records():
            temp_data = right_item[1]
            result_right_tuple.append((temp_data))

        return (result_inner_tuple, result_left_tuple, result_right_tuple)

    '''
    @method: set(tuple)
    @:return result_inner_list，result_left_list, result_right_list
    '''
    def check_set_datas(self, left_set, right_set):
        result_inner_list = left_set & right_set
        result_left_list = left_set - right_set
        result_right_list = right_set - left_set
        return (result_inner_list ,result_left_list, result_right_list)
